/**
 * React Router v6.4.2
 *
 * Copyright (c) Remix Software Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE.md file in the root directory of this source tree.
 *
 * @license MIT
 */
import{invariant as e,resolveTo as t,joinPaths as r,matchPath as n,parsePath as a,matchRoutes as o,Action as i,isRouteErrorResponse as l,createMemoryHistory as s,stripBasename as u,AbortedDeferredError as c,createRouter as d}from"@remix-run/router";export{AbortedDeferredError,Action as NavigationType,createPath,defer,generatePath,isRouteErrorResponse,json,matchPath,matchRoutes,parsePath,redirect,resolvePath}from"@remix-run/router";import*as p from"react";const h="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},{useState:m,useEffect:f,useLayoutEffect:v,useDebugValue:g}=p;function E(e){const t=e.getSnapshot,r=e.value;try{const e=t();return!h(r,e)}catch(n){return!0}}const x=!!("undefined"==typeof window||void 0===window.document||void 0===window.document.createElement)?function(e,t,r){return t()}:function(e,t,r){const n=t(),[{inst:a},o]=m({inst:{value:n,getSnapshot:t}});return v((()=>{a.value=n,a.getSnapshot=t,E(a)&&o({inst:a})}),[e,n,t]),f((()=>{E(a)&&o({inst:a});return e((()=>{E(a)&&o({inst:a})}))}),[e]),g(n),n},y="useSyncExternalStore"in p?p.useSyncExternalStore:x,C=p.createContext(null),b=p.createContext(null),R=p.createContext(null),S=p.createContext(null),P=p.createContext(null),D=p.createContext(null),U=p.createContext({outlet:null,matches:[]}),_=p.createContext(null);function w(t,{relative:n}={}){O()||e(!1);let{basename:a,navigator:o}=p.useContext(P),{hash:i,pathname:l,search:s}=I(t,{relative:n}),u=l;return"/"!==a&&(u="/"===l?a:r([a,l])),o.createHref({pathname:u,search:s,hash:i})}function O(){return null!=p.useContext(D)}function N(){return O()||e(!1),p.useContext(D).location}function j(){return p.useContext(D).navigationType}function A(t){O()||e(!1);let{pathname:r}=N();return p.useMemo((()=>n(t,r)),[r,t])}function F(e){return e.filter(((t,r)=>0===r||!t.route.index&&t.pathnameBase!==e[r-1].pathnameBase))}function k(){O()||e(!1);let{basename:n,navigator:a}=p.useContext(P),{matches:o}=p.useContext(U),{pathname:i}=N(),l=JSON.stringify(F(o).map((e=>e.pathnameBase))),s=p.useRef(!1);return p.useEffect((()=>{s.current=!0})),p.useCallback(((e,o={})=>{if(!s.current)return;if("number"==typeof e)return void a.go(e);let u=t(e,JSON.parse(l),i,"path"===o.relative);"/"!==n&&(u.pathname="/"===u.pathname?n:r([n,u.pathname])),(o.replace?a.replace:a.push)(u,o.state,o)}),[n,a,l,i])}const B=p.createContext(null);function M(){return p.useContext(B)}function L(e){let t=p.useContext(U).outlet;return t?p.createElement(B.Provider,{value:e},t):t}function T(){let{matches:e}=p.useContext(U),t=e[e.length-1];return t?t.params:{}}function I(e,{relative:r}={}){let{matches:n}=p.useContext(U),{pathname:a}=N(),o=JSON.stringify(F(n).map((e=>e.pathnameBase)));return p.useMemo((()=>t(e,JSON.parse(o),a,"path"===r)),[e,o,a,r])}function J(t,n){O()||e(!1);let l=p.useContext(R),{matches:s}=p.useContext(U),u=s[s.length-1],c=u?u.params:{};!u||u.pathname;let d=u?u.pathnameBase:"/";u&&u.route;let h,m=N();if(n){let t="string"==typeof n?a(n):n;"/"===d||t.pathname?.startsWith(d)||e(!1),h=t}else h=m;let f=h.pathname||"/",v="/"===d?f:f.slice(d.length)||"/",g=o(t,{pathname:v}),E=$(g&&g.map((e=>Object.assign({},e,{params:Object.assign({},c,e.params),pathname:r([d,e.pathname]),pathnameBase:"/"===e.pathnameBase?d:r([d,e.pathnameBase])}))),s,l||void 0);return n?p.createElement(D.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...h},navigationType:i.Pop}},E):E}function H(){let e=re(),t=l(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),r=e instanceof Error?e.stack:null,n="rgba(200,200,200, 0.5)",a={padding:"0.5rem",backgroundColor:n},o={padding:"2px 4px",backgroundColor:n};return p.createElement(p.Fragment,null,p.createElement("h2",null,"Unhandled Thrown Error!"),p.createElement("h3",{style:{fontStyle:"italic"}},t),r?p.createElement("pre",{style:a},r):null,p.createElement("p",null,"💿 Hey developer 👋"),p.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",p.createElement("code",{style:o},"errorElement")," props on ",p.createElement("code",{style:o},"<Route>")))}class z extends p.Component{constructor(e){super(e),this.state={location:e.location,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location?{error:e.error,location:e.location}:{error:e.error||t.error,location:t.location}}componentDidCatch(e,t){console.error("React Router caught the following error during render",e,t)}render(){return this.state.error?p.createElement(_.Provider,{value:this.state.error,children:this.props.component}):this.props.children}}function V({routeContext:e,match:t,children:r}){let n=p.useContext(C);return n&&t.route.errorElement&&(n._deepestRenderedBoundaryId=t.route.id),p.createElement(U.Provider,{value:e},r)}function $(t,r=[],n){if(null==t){if(!n?.errors)return null;t=n.matches}let a=t,o=n?.errors;if(null!=o){let t=a.findIndex((e=>e.route.id&&o?.[e.route.id]));t>=0||e(!1),a=a.slice(0,Math.min(a.length,t+1))}return a.reduceRight(((e,t,i)=>{let l=t.route.id?o?.[t.route.id]:null,s=n?t.route.errorElement||p.createElement(H,null):null,u=()=>p.createElement(V,{match:t,routeContext:{outlet:e,matches:r.concat(a.slice(0,i+1))}},l?s:void 0!==t.route.element?t.route.element:e);return n&&(t.route.errorElement||0===i)?p.createElement(z,{location:n.location,component:s,error:l,children:u()}):u()}),null)}var W,X,Y;function q(t){let r=p.useContext(R);return r||e(!1),r}function G(){return q(X.UseNavigation).navigation}function K(){let t=function(t){let r=p.useContext(b);return r||e(!1),r}(W.UseRevalidator),r=q(X.UseRevalidator);return{revalidate:t.router.revalidate,state:r.revalidation}}function Q(){let{matches:e,loaderData:t}=q(X.UseMatches);return p.useMemo((()=>e.map((e=>{let{pathname:r,params:n}=e;return{id:e.route.id,pathname:r,params:n,data:t[e.route.id],handle:e.route.handle}}))),[e,t])}function Z(){let t=q(X.UseLoaderData),r=p.useContext(U);r||e(!1);let n=r.matches[r.matches.length-1];return n.route.id||e(!1),t.loaderData[n.route.id]}function ee(e){return q(X.UseRouteLoaderData).loaderData[e]}function te(){let t=q(X.UseActionData);return p.useContext(U)||e(!1),Object.values(t?.actionData||{})[0]}function re(){let t=p.useContext(_),r=q(X.UseRouteError),n=p.useContext(U),a=n.matches[n.matches.length-1];return t||(n||e(!1),a.route.id||e(!1),r.errors?.[a.route.id])}function ne(){return p.useContext(S)?._data}function ae(){return p.useContext(S)?._error}function oe({fallbackElement:e,router:t}){let r=y(t.subscribe,(()=>t.state),(()=>t.state)),n=p.useMemo((()=>({createHref:t.createHref,go:e=>t.navigate(e),push:(e,r,n)=>t.navigate(e,{state:r,preventScrollReset:n?.preventScrollReset}),replace:(e,r,n)=>t.navigate(e,{replace:!0,state:r,preventScrollReset:n?.preventScrollReset})})),[t]),a=t.basename||"/";return p.createElement(b.Provider,{value:{router:t,navigator:n,static:!1,basename:a}},p.createElement(R.Provider,{value:r},p.createElement(ce,{basename:t.basename,location:t.state.location,navigationType:t.state.historyAction,navigator:n},t.state.initialized?p.createElement(de,null):e)))}function ie({basename:e,children:t,initialEntries:r,initialIndex:n}){let a=p.useRef();null==a.current&&(a.current=s({initialEntries:r,initialIndex:n,v5Compat:!0}));let o=a.current,[i,l]=p.useState({action:o.action,location:o.location});return p.useLayoutEffect((()=>o.listen(l)),[o]),p.createElement(ce,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:o})}function le({to:t,replace:r,state:n,relative:a}){O()||e(!1);let o=p.useContext(R),i=k();return p.useEffect((()=>{o&&"idle"!==o.navigation.state||i(t,{replace:r,state:n,relative:a})})),null}function se(e){return L(e.context)}function ue(t){e(!1)}function ce({basename:t="/",children:r=null,location:n,navigationType:o=i.Pop,navigator:l,static:s=!1}){O()&&e(!1);let c=t.replace(/^\/*/,"/"),d=p.useMemo((()=>({basename:c,navigator:l,static:s})),[c,l,s]);"string"==typeof n&&(n=a(n));let{pathname:h="/",search:m="",hash:f="",state:v=null,key:g="default"}=n,E=p.useMemo((()=>{let e=u(h,c);return null==e?null:{pathname:e,search:m,hash:f,state:v,key:g}}),[c,h,m,f,v,g]);return null==E?null:p.createElement(P.Provider,{value:d},p.createElement(D.Provider,{children:r,value:{location:E,navigationType:o}}))}function de({children:e,location:t}){let r=p.useContext(b);return J(r&&!e?r.router.routes:ve(e),t)}function pe({children:e,errorElement:t,resolve:r}){return p.createElement(me,{resolve:r,errorElement:t},p.createElement(fe,null,e))}!function(e){e.UseRevalidator="useRevalidator"}(W||(W={})),function(e){e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator"}(X||(X={})),function(e){e[e.pending=0]="pending",e[e.success=1]="success",e[e.error=2]="error"}(Y||(Y={}));const he=new Promise((()=>{}));class me extends p.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error("<Await> caught the following error during render",e,t)}render(){let{children:e,errorElement:t,resolve:r}=this.props,n=null,a=Y.pending;if(r instanceof Promise)if(this.state.error){a=Y.error;let e=this.state.error;n=Promise.reject().catch((()=>{})),Object.defineProperty(n,"_tracked",{get:()=>!0}),Object.defineProperty(n,"_error",{get:()=>e})}else r._tracked?(n=r,a=void 0!==n._error?Y.error:void 0!==n._data?Y.success:Y.pending):(a=Y.pending,Object.defineProperty(r,"_tracked",{get:()=>!0}),n=r.then((e=>Object.defineProperty(r,"_data",{get:()=>e})),(e=>Object.defineProperty(r,"_error",{get:()=>e}))));else a=Y.success,n=Promise.resolve(),Object.defineProperty(n,"_tracked",{get:()=>!0}),Object.defineProperty(n,"_data",{get:()=>r});if(a===Y.error&&n._error instanceof c)throw he;if(a===Y.error&&!t)throw n._error;if(a===Y.error)return p.createElement(S.Provider,{value:n,children:t});if(a===Y.success)return p.createElement(S.Provider,{value:n,children:e});throw n}}function fe({children:e}){let t=ne();return"function"==typeof e?e(t):p.createElement(p.Fragment,null,e)}function ve(t,r=[]){let n=[];return p.Children.forEach(t,((t,a)=>{if(!p.isValidElement(t))return;if(t.type===p.Fragment)return void n.push.apply(n,ve(t.props.children,r));t.type!==ue&&e(!1),t.props.index&&t.props.children&&e(!1);let o=[...r,a],i={id:t.props.id||o.join("-"),caseSensitive:t.props.caseSensitive,element:t.props.element,index:t.props.index,path:t.props.path,loader:t.props.loader,action:t.props.action,errorElement:t.props.errorElement,hasErrorBoundary:null!=t.props.errorElement,shouldRevalidate:t.props.shouldRevalidate,handle:t.props.handle};t.props.children&&(i.children=ve(t.props.children,o)),n.push(i)})),n}function ge(e){return $(e)}function Ee(e){return e.map((e=>{let t={...e};return null==t.hasErrorBoundary&&(t.hasErrorBoundary=null!=t.errorElement),t.children&&(t.children=Ee(t.children)),t}))}function xe(e,t){return d({basename:t?.basename,history:s({initialEntries:t?.initialEntries,initialIndex:t?.initialIndex}),hydrationData:t?.hydrationData,routes:Ee(e)}).initialize()}export{pe as Await,ie as MemoryRouter,le as Navigate,se as Outlet,ue as Route,ce as Router,oe as RouterProvider,de as Routes,b as UNSAFE_DataRouterContext,R as UNSAFE_DataRouterStateContext,C as UNSAFE_DataStaticRouterContext,D as UNSAFE_LocationContext,P as UNSAFE_NavigationContext,U as UNSAFE_RouteContext,Ee as UNSAFE_enhanceManualRouteObjects,xe as createMemoryRouter,ve as createRoutesFromChildren,ve as createRoutesFromElements,ge as renderMatches,te as useActionData,ae as useAsyncError,ne as useAsyncValue,w as useHref,O as useInRouterContext,Z as useLoaderData,N as useLocation,A as useMatch,Q as useMatches,k as useNavigate,G as useNavigation,j as useNavigationType,L as useOutlet,M as useOutletContext,T as useParams,I as useResolvedPath,K as useRevalidator,re as useRouteError,ee as useRouteLoaderData,J as useRoutes};
//# sourceMappingURL=react-router.production.min.js.map
